FROM alpine:3.12

RUN apk add --no-cache npm git
RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
RUN cnpm install -g gitbook-cli
RUN cnpm cache clean -f
RUN sed -i "s/fs.stat = statFix(fs.stat)/\/\/ fs.stat = statFix(fs.stat)/g" /usr/lib/node_modules/gitbook-cli/node_modules/_npm@5.1.0@npm/node_modules/graceful-fs/polyfills.js
RUN sed -i "s/fs.fstat = statFix(fs.fstat)/\/\/ fs.fstat = statFix(fs.fstat)/g" /usr/lib/node_modules/gitbook-cli/node_modules/_npm@5.1.0@npm/node_modules/graceful-fs/polyfills.js
RUN sed -i "s/fs.lstat = statFix(fs.lstat)/\/\/ fs.lstat = statFix(fs.lstat)/g" /usr/lib/node_modules/gitbook-cli/node_modules/_npm@5.1.0@npm/node_modules/graceful-fs/polyfills.js

RUN gitbook -V

# 修复3.2.3的bug
RUN sed -i "s/confirm: true/confirm: false/g" /root/.gitbook/versions/3.2.3/lib/output/website/copyPluginAssets.js

WORKDIR /www